

api_key =""
model = 'ep-20241104131149-csxf9'
base_url = "https://ark.cn-beijing.volces.com/api/v3"


from openai import OpenAI  # 导入OpenAI

prompt_text = "您是一位专业的鲜花店文案撰写员。对于售价为{}元的{}，您能提供一个吸引人的简短描述吗？"  # 设置提示

flowers = ["玫瑰", "百合", "康乃馨"]
prices = ["50", "30", "20"]

# 循环调用Text模型的Completion方法，生成文案
for flower, price in zip(flowers, prices):
    prompt = prompt_text.format(price, flower)
    client = OpenAI(
        api_key=api_key,
        base_url=base_url)
    response = client.chat.completions.create(
        
        model=model,
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": prompt},
        ],
        max_tokens=100,
    )

    print(response.choices[0].message.content)
